package com.ruoyi.activiti.listener;

import com.ruoyi.caigou.api.RemoteBuyBackReqService;
import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.caigou.BuyBackReq;
import com.ruoyi.xiaoshou.api.RemoteSaleReqService;
import com.ruoyi.xiaoshou.domain.SaleRequest;
import lombok.extern.slf4j.Slf4j;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
@Slf4j
public class SaleRequestListener implements ExecutionListener {


    public void notify(DelegateExecution delegateExecution) {
        SaleRequest saleRequest = new SaleRequest();
        saleRequest.setCode(delegateExecution.getProcessInstanceBusinessKey());
        saleRequest.setStatus((Integer) delegateExecution.getVariable("approvalResult"));
        saleRequest.setAuditName(SecurityUtils.getUsername());
        //TODO 审核意见
        log.info("SaleRequestListener notify saleRequest:{} ", saleRequest);
        //TODO 调用销售申请修改接口
        AjaxResult ajaxResult = SpringUtils.getBean(RemoteSaleReqService.class).updSaleReq(saleRequest);
        log.info("ajaxResult:{}", ajaxResult);
    }
}
